'use strict';

/* Controllers */

var app = angular.module('app.controllers', ['pascalprecht.translate', 'ngCookies'])
  .controller('AppCtrl', ['$rootScope', '$scope', '$translate', '$localStorage', '$window',
    function ($rootScope, $scope, $translate, $localStorage, $window) {
        // add 'ie' classes to html
        var isIE = !!navigator.userAgent.match(/MSIE/i);
        isIE && angular.element($window.document.body).addClass('ie');
        isSmartDevice($window) && angular.element($window.document.body).addClass('smart');

        //平台、设备和操作系统   
        var system ={  
            win : false,  
            mac : false,  
            xll : false  
        };  
        //检测平台   
        var p = navigator.platform;  
        system.win = p.indexOf("Win") == 0;  
        system.mac = p.indexOf("Mac") == 0;  
        system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);  
        //跳转语句   
        if (system.win || system.mac || system.xll) { //转向电脑端
            //window.location.href="http://www.baidu.com";  
            
        } else {
            //window.location.href = "img.jobsloveme.com";
        }//转向手机端}



        // config
        $scope.app = {
            name: $rootScope.name,
            version: '1.1.3',
            // for chart colors
            color: {
                primary: '#7266ba',
                info: '#23b7e5',
                success: '#27c24c',
                warning: '#fad733',
                danger: '#f05050',
                light: '#e8eff0',
                dark: '#3a3f51',
                black: '#1c2b36'
            },
            settings: {
                themeID: 1,
                navbarHeaderColor: 'bg-black',
                navbarCollapseColor: '',//bg-white-only
                asideColor: 'bg-black',
                headerFixed: true,
                asideFixed: false,
                asideFolded: false
            }
        }

        $rootScope.$watch('name', function (newVal, oldVal) {
            $scope.app.name = $rootScope.name;
        });

        // save settings to local storage
        if (angular.isDefined($localStorage.settings)) {
            $scope.app.settings = $localStorage.settings;
        } else {
            $localStorage.settings = $scope.app.settings;
        }
        $scope.$watch('app.settings', function () { $localStorage.settings = $scope.app.settings; }, true);

        // angular translate
        $scope.lang = { isopen: false };
        $scope.langs = { en: 'English', de_DE: 'German', it_IT: 'Italian' };
        $scope.selectLang = $scope.langs[$translate.proposedLanguage()] || "English";
        $scope.setLang = function (langKey, $event) {
            // set the current lang
            $scope.selectLang = $scope.langs[langKey];
            // You can change the language during runtime
            $translate.use(langKey);
            $scope.lang.isopen = !$scope.lang.isopen;
        };

        function isSmartDevice($window) {
            // Adapted from http://www.detectmobilebrowsers.com
            var ua = $window['navigator']['userAgent'] || $window['navigator']['vendor'] || $window['opera'];
            // Checks for iOs, Android, Blackberry, Opera Mini, and Windows mobile devices
            return (/iPhone|iPod|iPad|Silk|Android|BlackBerry|Opera Mini|IEMobile/).test(ua);
        }

    }])

  // bootstrap controller
  .controller('AccordionDemoCtrl', ['$scope', function ($scope) {
      $scope.oneAtATime = true;

      $scope.groups = [
        {
            title: 'Accordion group header - #1',
            content: 'Dynamic group body - #1'
        },
        {
            title: 'Accordion group header - #2',
            content: 'Dynamic group body - #2'
        }
      ];

      $scope.items = ['Item 1', 'Item 2', 'Item 3'];

      $scope.addItem = function () {
          var newItemNo = $scope.items.length + 1;
          $scope.items.push('Item ' + newItemNo);
      };

      $scope.status = {
          isFirstOpen: true,
          isFirstDisabled: false
      };
  }])
  .controller('AlertDemoCtrl', ['$scope', function ($scope) {
      $scope.alerts = [
        { type: 'success', msg: 'Well done! You successfully read this important alert message.' },
        { type: 'info', msg: 'Heads up! This alert needs your attention, but it is not super important.' },
        { type: 'warning', msg: 'Warning! Best check yo self, you are not looking too good...' }
      ];

      $scope.addAlert = function () {
          $scope.alerts.push({ type: 'danger', msg: 'Oh snap! Change a few things up and try submitting again.' });
      };

      $scope.closeAlert = function (index) {
          $scope.alerts.splice(index, 1);
      };
  }])
  .controller('ButtonsDemoCtrl', ['$scope', function ($scope) {
      $scope.singleModel = 1;

      $scope.radioModel = 'Middle';

      $scope.checkModel = {
          left: false,
          middle: true,
          right: false
      };
  }])
  .controller('CarouselDemoCtrl', ['$scope', '$window', function ($scope, $window) {
      $scope.myInterval = 5000;
      var slides = $scope.slides = [];
      $scope.addSlide = function () {
          slides.push({
              image: 'img/c' + slides.length + '.jpg',
              text: ['', '', '', ''][slides.length % 4]
          });
      };
      for (var i = 0; i < 4; i++) {
          $scope.addSlide();
      }

     


  }])
  .controller('DropdownDemoCtrl', ['$scope', function ($scope) {
      $scope.items = [
        'The first choice!',
        'And another choice for you.',
        'but wait! A third!'
      ];

      $scope.status = {
          isopen: false
      };

      $scope.toggled = function (open) {
          //console.log('Dropdown is now: ', open);
      };

      $scope.toggleDropdown = function ($event) {
          $event.preventDefault();
          $event.stopPropagation();
          $scope.status.isopen = !$scope.status.isopen;
      };
  }])
  .controller('ModalDemoCtrl', ['$scope', '$modal', '$log', function ($scope, $modal, $log) {
      $scope.items = ['item1', 'item2', 'item3'];
      var ModalInstanceCtrl = function ($scope, $modalInstance, items) {
          $scope.items = items;
          $scope.selected = {
              item: $scope.items[0]
          };

          $scope.ok = function () {
              $modalInstance.close($scope.selected.item);
          };

          $scope.cancel = function () {
              $modalInstance.dismiss('cancel');
          };
      };

      $scope.open = function (size) {
          var modalInstance = $modal.open({
              templateUrl: 'myModalContent.html',
              controller: ModalInstanceCtrl,
              size: size,
              resolve: {
                  items: function () {
                      return $scope.items;
                  }
              }
          });

          modalInstance.result.then(function (selectedItem) {
              $scope.selected = selectedItem;
          }, function () {
              $log.info('Modal dismissed at: ' + new Date());
          });
      };
  }])
  .controller('PaginationDemoCtrl', ['$scope', '$log', function ($scope, $log) {
      $scope.totalItems = 64;
      $scope.currentPage = 4;

      $scope.setPage = function (pageNo) {
          $scope.currentPage = pageNo;
      };

      $scope.pageChanged = function () {
          $log.info('Page changed to: ' + $scope.currentPage);
      };

      $scope.maxSize = 5;
      $scope.bigTotalItems = 175;
      $scope.bigCurrentPage = 1;
  }])
  .controller('PopoverDemoCtrl', ['$scope', function ($scope) {
      $scope.dynamicPopover = 'Hello, World!';
      $scope.dynamicPopoverTitle = 'Title';
  }])
  .controller('ProgressDemoCtrl', ['$scope', function ($scope) {
      $scope.max = 200;

      $scope.random = function () {
          var value = Math.floor((Math.random() * 100) + 1);
          var type;

          if (value < 25) {
              type = 'success';
          } else if (value < 50) {
              type = 'info';
          } else if (value < 75) {
              type = 'warning';
          } else {
              type = 'danger';
          }

          $scope.showWarning = (type === 'danger' || type === 'warning');

          $scope.dynamic = value;
          $scope.type = type;
      };
      $scope.random();

      $scope.randomStacked = function () {
          $scope.stacked = [];
          var types = ['success', 'info', 'warning', 'danger'];

          for (var i = 0, n = Math.floor((Math.random() * 4) + 1) ; i < n; i++) {
              var index = Math.floor((Math.random() * 4));
              $scope.stacked.push({
                  value: Math.floor((Math.random() * 30) + 1),
                  type: types[index]
              });
          }
      };
      $scope.randomStacked();
  }])
  .controller('TabsDemoCtrl', ['$scope', function ($scope) {
      $scope.tabs = [
        { title: 'Dynamic Title 1', content: 'Dynamic content 1' },
        { title: 'Dynamic Title 2', content: 'Dynamic content 2', disabled: true }
      ];
  }])
  .controller('RatingDemoCtrl', ['$scope', function ($scope) {
      $scope.rate = 7;
      $scope.max = 10;
      $scope.isReadonly = false;

      $scope.hoveringOver = function (value) {
          $scope.overStar = value;
          $scope.percent = 100 * (value / $scope.max);
      };
  }])
  .controller('TooltipDemoCtrl', ['$scope', function ($scope) {
      $scope.dynamicTooltip = 'Hello, World!';
      $scope.dynamicTooltipText = 'dynamic';
      $scope.htmlTooltip = 'I\'ve been made <b>bold</b>!';
  }])
  .controller('TypeaheadDemoCtrl', ['$scope', '$http', function ($scope, $http) {
      $scope.selected = undefined;
      $scope.states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Dakota', 'North Carolina', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'];
      // Any function returning a promise object can be used to load values asynchronously
      $scope.getLocation = function (val) {
          return $http.get('http://maps.googleapis.com/maps/api/geocode/json', {
              params: {
                  address: val,
                  sensor: false
              }
          }).then(function (res) {
              var addresses = [];
              angular.forEach(res.data.results, function (item) {
                  addresses.push(item.formatted_address);
              });
              return addresses;
          });
      };
  }])
  .controller('DatepickerDemoCtrl', ['$scope', function ($scope) {
      $scope.today = function () {
          $scope.dt = new Date();
      };
      $scope.today();

      $scope.clear = function () {
          $scope.dt = null;
      };

      // Disable weekend selection
      $scope.disabled = function (date, mode) {
          return (mode === 'day' && (date.getDay() === 0 || date.getDay() === 6));
      };

      $scope.toggleMin = function () {
          $scope.minDate = $scope.minDate ? null : new Date();
      };
      $scope.toggleMin();

      $scope.open = function ($event) {
          $event.preventDefault();
          $event.stopPropagation();

          $scope.opened = true;
      };

      $scope.dateOptions = {
          formatYear: 'yy',
          startingDay: 1,
          class: 'datepicker'
      };

      $scope.initDate = new Date('2016-15-20');
      $scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
      $scope.format = $scope.formats[0];
  }])
  .controller('TimepickerDemoCtrl', ['$scope', function ($scope) {
      $scope.mytime = new Date();

      $scope.hstep = 1;
      $scope.mstep = 15;

      $scope.options = {
          hstep: [1, 2, 3],
          mstep: [1, 5, 10, 15, 25, 30]
      };

      $scope.ismeridian = true;
      $scope.toggleMode = function () {
          $scope.ismeridian = !$scope.ismeridian;
      };

      $scope.update = function () {
          var d = new Date();
          d.setHours(14);
          d.setMinutes(0);
          $scope.mytime = d;
      };

      $scope.changed = function () {
          //console.log('Time changed to: ' + $scope.mytime);
      };

      $scope.clear = function () {
          $scope.mytime = null;
      };
  }])

  // Form controller
  .controller('FormDemoCtrl', ['$scope', function ($scope) {
      $scope.notBlackListed = function (value) {
          var blacklist = ['bad@domain.com', 'verybad@domain.com'];
          return blacklist.indexOf(value) === -1;
      }

      $scope.val = 15;
      var updateModel = function (val) {
          $scope.$apply(function () {
              $scope.val = val;
          });
      };
      angular.element("#slider").on('slideStop', function (data) {
          updateModel(data.value);
      });

      $scope.select2Number = [
        { text: 'First', value: 'One' },
        { text: 'Second', value: 'Two' },
        { text: 'Third', value: 'Three' }
      ];

      $scope.list_of_string = ['tag1', 'tag2']
      $scope.select2Options = {
          'multiple': true,
          'simple_tags': true,
          'tags': ['tag1', 'tag2', 'tag3', 'tag4']  // Can be empty list.
      };

  }])

  // Flot Chart controller 
  .controller('FlotChartDemoCtrl', ['$scope', function ($scope) {
      $scope.d = [[1, 6.5], [2, 6.5], [3, 7], [4, 8], [5, 7.5], [6, 7], [7, 6.8], [8, 7], [9, 7.2], [10, 7], [11, 6.8], [12, 7]];

      $scope.d0_1 = [[0, 7], [1, 6.5], [2, 12.5], [3, 7], [4, 9], [5, 6], [6, 11], [7, 6.5], [8, 8], [9, 7]];

      $scope.d0_2 = [[0, 4], [1, 4.5], [2, 7], [3, 4.5], [4, 3], [5, 3.5], [6, 6], [7, 3], [8, 4], [9, 3]];

      $scope.d1_1 = [[10, 120], [20, 70], [30, 70], [40, 60]];

      $scope.d1_2 = [[10, 50], [20, 60], [30, 90], [40, 35]];

      $scope.d1_3 = [[10, 80], [20, 40], [30, 30], [40, 20]];

      $scope.d2 = [];

      for (var i = 0; i < 20; ++i) {
          $scope.d2.push([i, Math.sin(i)]);
      }

      $scope.d3 = [
        { label: "iPhone5S", data: 40 },
        { label: "iPad Mini", data: 10 },
        { label: "iPad Mini Retina", data: 20 },
        { label: "iPhone4S", data: 12 },
        { label: "iPad Air", data: 18 }
      ];

      $scope.getRandomData = function () {
          var data = [],
          totalPoints = 150;
          if (data.length > 0)
              data = data.slice(1);
          while (data.length < totalPoints) {
              var prev = data.length > 0 ? data[data.length - 1] : 50,
                y = prev + Math.random() * 10 - 5;
              if (y < 0) {
                  y = 0;
              } else if (y > 100) {
                  y = 100;
              }
              data.push(y);
          }
          // Zip the generated y values with the x values
          var res = [];
          for (var i = 0; i < data.length; ++i) {
              res.push([i, data[i]])
          }
          return res;
      }

      $scope.d4 = $scope.getRandomData();
  }])

  // jVectorMap controller
  .controller('JVectorMapDemoCtrl', ['$scope', function ($scope) {
      $scope.world_markers = [
        { latLng: [41.90, 12.45], name: 'Vatican City' },
        { latLng: [43.73, 7.41], name: 'Monaco' },
        { latLng: [-0.52, 166.93], name: 'Nauru' },
        { latLng: [-8.51, 179.21], name: 'Tuvalu' },
        { latLng: [43.93, 12.46], name: 'San Marino' },
        { latLng: [47.14, 9.52], name: 'Liechtenstein' },
        { latLng: [7.11, 171.06], name: 'Marshall Islands' },
        { latLng: [17.3, -62.73], name: 'Saint Kitts and Nevis' },
        { latLng: [3.2, 73.22], name: 'Maldives' },
        { latLng: [35.88, 14.5], name: 'Malta' },
        { latLng: [12.05, -61.75], name: 'Grenada' },
        { latLng: [13.16, -61.23], name: 'Saint Vincent and the Grenadines' },
        { latLng: [13.16, -59.55], name: 'Barbados' },
        { latLng: [17.11, -61.85], name: 'Antigua and Barbuda' },
        { latLng: [-4.61, 55.45], name: 'Seychelles' },
        { latLng: [7.35, 134.46], name: 'Palau' },
        { latLng: [42.5, 1.51], name: 'Andorra' },
        { latLng: [14.01, -60.98], name: 'Saint Lucia' },
        { latLng: [6.91, 158.18], name: 'Federated States of Micronesia' },
        { latLng: [1.3, 103.8], name: 'Singapore' },
        { latLng: [1.46, 173.03], name: 'Kiribati' },
        { latLng: [-21.13, -175.2], name: 'Tonga' },
        { latLng: [15.3, -61.38], name: 'Dominica' },
        { latLng: [-20.2, 57.5], name: 'Mauritius' },
        { latLng: [26.02, 50.55], name: 'Bahrain' },
        { latLng: [0.33, 6.73], name: 'São Tomé and Príncipe' }
      ];

      $scope.usa_markers = [
        { latLng: [40.71, -74.00], name: 'New York' },
        { latLng: [34.05, -118.24], name: 'Los Angeles' },
        { latLng: [41.87, -87.62], name: 'Chicago' },
        { latLng: [29.76, -95.36], name: 'Houston' },
        { latLng: [39.95, -75.16], name: 'Philadelphia' },
        { latLng: [38.90, -77.03], name: 'Washington' },
        { latLng: [37.36, -122.03], name: 'Silicon Valley' }
      ];
  }])

  // signin controller
  .controller('SigninFormController', ['$scope', '$http', '$state', function ($scope, $http, $state) {
      $scope.user = {};
      $scope.authError = null;
      $scope.login = function () {
          $scope.authError = null;
          // Try to login
          $http.post('api/login', { email: $scope.user.email, password: $scope.user.password })
          .then(function (response) {
              if (!response.data.user) {
                  $scope.authError = 'Email or Password not right';
              } else {
                  $state.go('app.dashboard');
              }
          }, function (x) {
              $scope.authError = 'Server Error';
          });
      };
  }])

  // signup controller
  .controller('SignupFormController', ['$window', '$scope', '$http', '$state', function ($window, $scope, $http, $state) {
      $scope.user = {};
      $scope.authError = null;
      $scope.signup = function () {
          //$scope.authError = null;
          //// Try to create
          //$http.post('api/signup', {name: $scope.user.name, email: $scope.user.email, password: $scope.user.password})
          //.then(function(response) {
          //  if ( !response.data.user ) {
          //    $scope.authError = response;
          //  }else{
          //    $state.go('app.dashboard');
          //  }
          //}, function(x) {
          //  $scope.authError = 'Server Error';
          //});


          $window.location.href = '#/zhuce/register'

      };
  }])



.controller('RegisterController', ['$scope', '$http', '$state', function ($scope, $http, $state) {
   

}])
    .controller('adragonCtrl', ['$scope', '$http', '$state', function ($scope, $http, $state) {
        $scope.oneAtATime0 = true;
        $scope.oneAtATime1 = true;

        $scope.oneAtATime2 = true;
        $scope.oneAtATime3 = true;
        $scope.oneAtATime4 = true;
        $scope.oneAtATime5 = true;

        $scope.price;
        
        $scope.sum = function () {
           
           
            if ($scope.oneAtATime0 == true || $scope.oneAtATime2 == true) {
                $scope.price = "免费";
            } else {
                $scope.price = "劳务费 : 1000";
            }
        }



    }])

.controller('EatController', ['$scope', 'NgMap', 'NavigatorGeolocation', function ($scope, NgMap, NavigatorGeolocation) {




    var WGS84_to_GCJ02 = function () { }

    var a = 6378245.0;
    var ee = 0.00669342162296594323;

    function outOfChina(lat, lon) {

        if (lon < 72.004 || lon > 137.8347)
            return true;
        if (lat < 0.8293 || lat > 55.8271)
            return true;

        return false;

    };

    function transformLat(x, y) {

        var ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
        ret += (20.0 * Math.sin(6.0 * x * Math.PI) + 20.0 * Math.sin(2.0 * x * Math.PI)) * 2.0 / 3.0;
        ret += (20.0 * Math.sin(y * Math.PI) + 40.0 * Math.sin(y / 3.0 * Math.PI)) * 2.0 / 3.0;
        ret += (160.0 * Math.sin(y / 12.0 * Math.PI) + 320 * Math.sin(y * Math.PI / 30.0)) * 2.0 / 3.0;

        return ret;

    };

    function transformLon(x, y) {

        var ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
        ret += (20.0 * Math.sin(6.0 * x * Math.PI) + 20.0 * Math.sin(2.0 * x * Math.PI)) * 2.0 / 3.0;
        ret += (20.0 * Math.sin(x * Math.PI) + 40.0 * Math.sin(x / 3.0 * Math.PI)) * 2.0 / 3.0;
        ret += (150.0 * Math.sin(x / 12.0 * Math.PI) + 300.0 * Math.sin(x / 30.0 * Math.PI)) * 2.0 / 3.0;

        return ret;

    };
    function transform(wgLat, wgLon) {

        if (outOfChina(wgLat, wgLon)) {
            return [wgLat, wgLon];
        }


        var dLat = transformLat(wgLon - 105.0, wgLat - 35.0);
        var dLon = transformLon(wgLon - 105.0, wgLat - 35.0);
        var radLat = wgLat / 180.0 * Math.PI;
        var magic = Math.sin(radLat);
        magic = 1 - ee * magic * magic;
        var sqrtMagic = Math.sqrt(magic);
        dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * Math.PI);
        dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * Math.PI);
        var mgLat = wgLat + dLat;
        var mgLon = wgLon + dLon;

        return [mgLat, mgLon];

    };




    var TILE_SIZE = 256;

    function bound(value, opt_min, opt_max) {
        if (opt_min != null) value = Math.max(value, opt_min);
        if (opt_max != null) value = Math.min(value, opt_max);
        return value;
    }

    function degreesToRadians(deg) {
        return deg * (Math.PI / 180);
    }

    function radiansToDegrees(rad) {
        return rad / (Math.PI / 180);
    }

    function MercatorProjection() {
        this.pixelOrigin_ = new google.maps.Point(TILE_SIZE / 2, TILE_SIZE / 2);
        this.pixelsPerLonDegree_ = TILE_SIZE / 360;
        this.pixelsPerLonRadian_ = TILE_SIZE / (2 * Math.PI);
    }

    MercatorProjection.prototype.fromLatLngToPoint = function (latLng,
        opt_point) {
        var me = this;
        var point = opt_point || new google.maps.Point(0, 0);
        var origin = me.pixelOrigin_;

        point.x = origin.x + latLng.lng * me.pixelsPerLonDegree_;

        // Truncating to 0.9999 effectively limits latitude to 89.189. This is
        // about a third of a tile past the edge of the world tile.
        var siny = bound(Math.sin(degreesToRadians(latLng.lat)), -0.9999,
            0.9999);
        point.y = origin.y + 0.5 * Math.log((1 + siny) / (1 - siny)) *
            -me.pixelsPerLonRadian_;
        return point;
    };

    MercatorProjection.prototype.fromPointToLatLng = function (point) {
        var me = this;
        var origin = me.pixelOrigin_;
        var lng = (point.x - origin.x) / me.pixelsPerLonDegree_;
        var latRadians = (point.y - origin.y) / -me.pixelsPerLonRadian_;
        var lat = radiansToDegrees(2 * Math.atan(Math.exp(latRadians)) -
            Math.PI / 2);
        return new google.maps.LatLng(lat, lng);
    };

    var vm = this;
    NgMap.getMap().then(function (map) {
        var numTiles = 1 << map.getZoom();
        var projection = new MercatorProjection();


        NavigatorGeolocation.getCurrentPosition()
          .then(function (position) {

              //console.log(position.coords.latitude);

              var coords = position.coords;
              //var latlng = new google.maps.LatLng(coords.latitude, coords.longitude);
              //var GCJ02loc = new WGS84_to_GCJ02().transform(coords.latitude, coords.longitude);

              //var latlng = new google.maps.LatLng(position.coords.latitude,  position.coords.longitude);
              var GCJ02loc = transform(position.coords.latitude, position.coords.longitude);



              //latlng = new google.maps.LatLng(GCJ02loc[0], GCJ02loc[1])

              var lat = GCJ02loc[0], lng = GCJ02loc[1];

              //var lat = position.coords.latitude, lng = position.coords.longitude;

              console.log(lat);

              vm.chicago = { "lat": lat, "lng": lng };

              vm.map = map;

              vm.map.setCenter(vm.chicago);

              vm.worldCoordinate = projection.fromLatLngToPoint(vm.chicago);
              vm.pixelCoordinate = new google.maps.Point(
                  vm.worldCoordinate.x * numTiles,
                  vm.worldCoordinate.y * numTiles);
              vm.tileCoordinate = new google.maps.Point(
                  Math.floor(vm.pixelCoordinate.x / TILE_SIZE),
                  Math.floor(vm.pixelCoordinate.y / TILE_SIZE));

          });


        vm.closeCustomMarker = function (evt) {


            for (var i = 0; i < map.customMarkers.length; i++) {
                map.customMarkers[i].setVisible(false);
                //map.customMarkers[i].setVisible(false);
            }

            this.style.display = 'none';
            //map.customMarkers[this.name].setVisible(false);
            //map.customMarkers[this.name].draw();
            map.customMarkers[this.name].draw();


        };

    });

    $scope.showName = "";

    //$scope.mouseover = function () {
    //    console.log('mouseover', this);
    //    this.style.backgroundColor = 'grey';
    //};
    //$scope.mouseout = function () {
    //    this.style.backgroundColor = 'white';
    //};
    $scope.click = function () { console.log('click') };
    $scope.customMarkers = [
      { address: "餐馆", "class": "my1", "id": "0" },
      { address: "东方新天地", "class": "my2", "id": "1" },
    ];
    $scope.world = "World";



    $scope.test = function () {




    }






}])



;